package com.sixth.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sixth.dao.ShaftchooseDao;
import com.sixth.entity.Keyboardcolor;
import com.sixth.entity.Keycap;
import com.sixth.entity.Shaftchoose;
import com.sixth.service.ShaftChooseService;
import com.sixth.util.CommonResult;
import com.sixth.util.TableLayUi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: project01
 * @description:
 * @author: 老魏
 * @create: 2021-12-27 14:51
 **/
@Service("/shaftChooseService")
public class ShaftChooseServiceImpl implements ShaftChooseService {
    @Autowired
    private ShaftchooseDao shaftchooseDao;

    public CommonResult findAllShaftChoose(){
        List<Shaftchoose> list = shaftchooseDao.selectAllShaftChoose();
        return  new CommonResult(0,"",list);
    }
    public  CommonResult deleteShaftChoose(Integer shaftchooseid){

        System.out.println("轴id++++++++++++"+shaftchooseid);

        int row = shaftchooseDao.deleteByPrimaryKey(shaftchooseid);
        if(row>0){
            return  new CommonResult(2000,"删除成功",null);
        }else {
            return  new CommonResult(5000,"删除失败",null);
        }
    }
    public  CommonResult updateShaftchoose(Shaftchoose record){
        int row = shaftchooseDao.updateByPrimaryKey(record);
        if(row>0){
            return  new CommonResult(2000,"修改成功",null);
        }else {
            return  new CommonResult(5000,"修改失败",null);
        }
    }
    public  CommonResult addShaftchoose(Shaftchoose record){
        int row = shaftchooseDao.insert(record);
        if(row>0){
            return  new CommonResult(2000,"新增成功",null);
        }else {
            return  new CommonResult(5000,"新增失败",null);
        }
    }

    public TableLayUi findshaftCondition (int page, int limit){
        PageHelper.startPage(page,limit);
        List<Shaftchoose> Shaftchooses= shaftchooseDao.selectshaftCondition();
        PageInfo<Shaftchoose> pageInfo= new PageInfo<Shaftchoose>(Shaftchooses);
        return new  TableLayUi(0,"",pageInfo.getTotal(),pageInfo.getList());
    }
}
